Draft DXF is a software module used by the Std Open,
Std Import and
Std Export commands to handle the DXF file format.
From the user's point of view, the DXF import/export module will be loaded automatically when any of those commands are invoked and the file to open, import or export is a DXF file. The main difference between Std Open and the import command is that the former will create a new FreeCAD document and then do the import, whereas the later will import the DXF file and insert the result in the currently active document.
Qcad drawing exported to DXF, which is subsequently opened in FreeCAD
Această funcție deschide un fișier DXF (orice versiune de la 12 la 2007) într-un nou desen. Următoarele tipuri de obiecte DXF sunt suportate în mod curent:
Alte entități DXF nu sunt importate în prezent deoarece nu există un obiect FreeCAD corespunzător. Odată cu implementarea noii funcționalități, va fi posibil să importați mai multe tipuri de entități.
Two importers are available, which one is used can be specified under Edit → Preferences... → Import-Export → DXF. One is built-in, C++-based and fast, the other is legacy, coded in Python, slower, and requires the installation of an add-on, but can handle some entities better and can create more refined FreeCAD objects. Both support all DXF versions starting from R12.
3D solids inside a DXF file are stored under a binary ACIS/SAT blob, which at the moment cannot be read by FreeCAD.
Entity | C++ importer | Legacy importer |
---|---|---|
Lines | ✓ | ✓ |
Polylines (and LWPOLYLINES) | ✓ | ✓ |
Arcs | ✓ | ✓ |
Circles | ✓ | ✓ |
Ellipses | ✓ | ✓ |
Splines | ✓ | ✓ |
Texts & MTexts | ✓ | ✓ |
Leaders | ✗ | ✓ |
Layers | ✓ | ✓ |
Points | ✓ | ✓ |
Dimensions | ✓ | ✓ |
Blocks | ✓ (Geometry only; texts, dimensions, and attributes inside blocks are skipped) |
✓ |
Paper space objects | ✓ | ✓ |
3D Faces | ✗ | ✓ |
DXF-ul exportat este compatibil cu versiunea Autocad 12 sau mai recentă, deci ar trebui să se deschidă în orice aplicație care suportă formatul dxf. În prezent, se exportă următoarele obiecte FreeCAD:
There are also two exporters. The legacy exporter exports to the R12 DXF format, the C++ exporter to the R14 DXF format. Both formats can be handled by many applications.
Feature | C++ exporter (R14) | Legacy exporter (R12) |
---|---|---|
Supported 2D Geometry | All except Bezier curves. Ellipses and Splines are exported natively. | All except Points. Ellipses and B-splines may be inaccurate or exported as polylines. |
Points | ✓ (If the "Export points" preference is enabled) |
✗ |
3D Objects | Edges from faces are exported. Curved edges only if on XY plane. May create duplicate lines. | Exported as flattened 2D views. |
Texts and Dimensions | ✗ | ✓ |
Colors | ✗ | ✓ (Based on object line color) |
Layers | ✓ (Mapped from object names) |
✓ (Mapped from layers and nested groups) |
Compounds | ✗ | ✓ (Exported as blocks) |
Warning: Din motive de licență, bibliotecile de import / export dxf nu mai fac parte din codul sursă al FreeCAD. Din acest motiv, ele trebuie să fie instalate de dvs., utilizatorul, după ce ați instalat FreeCAD. Există o modalitate de a permite FreeCAD să facă acest lucru în mod automat sau puteți să o faceți manual.
See Import Export Preferences.
Because the DWG format is a proprietary, closed and undocumented format it is hard for open-source projects like FreeCAD to support it. That is why FreeCAD relies on external converters to read and write DWG files. To import a DWG file a converter is used to create a DXF first, which can then be processed by the FreeCAD DXF importer. When exporting to DWG the opposite conversion happens: the DXF created by the FreeCAD DXF exporter is turned into a DWG.
Note that the DXF format allows a 1:1 conversion of the DWG format. All applications that can read and write DWG files can do the same with DXF files, with no data loss. So asking for DXF files instead of DWG files, and supplying DXF files in turn, should not cause any problems.
There is built-in support for the following DWG converters:
See Import Export Preferences and FreeCAD and DWG Import for more information.
See also: Autogenerated API documentation and FreeCAD Scripting Basics.
To export objects to DXF use the export
method of the importDXF module.
importDXF.export(objectslist, filename, nospline=False, lwPoly=False)
filename
.Example:
import FreeCAD as App
import Draft
import importDXF
doc = App.newDocument()
polygon1 = Draft.make_polygon(3, radius=500)
polygon2 = Draft.make_polygon(5, radius=1500)
doc.recompute()
objects = [polygon1, polygon2]
importDXF.export(objects, "/home/user/Pictures/myfile.dxf")